package service.person;

import dao.person.PersonDao;
import dao.person.PersonDapImpl;
import domain.Person;

import java.util.ArrayList;
import java.util.List;

public class PersonServiceImpl implements PersonService {
    PersonDao personDao = new PersonDapImpl();

    /**
     * 个人赛报名
     * @param name,sex,age,BM,phone,idcard,filename,isTeam
     * @return int
     * @author 夏添
     * @date 2020/7/23 9:25
     */
    public int onePerson(String name, String sex, int age, String phone, String idcard){
        int i = 0;
        String BM = "";
        if (sex.equals( "男")){
            BM = "个人男子组";
        }
        if(sex.equals( "女")){
            BM = "个人女子组";
        }
        try {
            i = personDao.CreatPerson(name,sex,age,BM,phone,idcard,"",0);
        }catch (Exception e){
            e.printStackTrace();
        }
        return i;
    }

    /**
     * 个人赛医护报名
     * @param name,sex,age,BM,phone,idcard,filename,isTeam
     * @return int
     * @author 夏添
     * @date 2020/7/23 9:25
     */
    public int threePerson(String name, String sex, int age, String phone, String idcard, String filename){
        int i = 0;
        try {
            i = personDao.CreatPerson(name,sex,age,"白衣天使组",phone,idcard,filename,0);
        }catch (Exception e){
            e.printStackTrace();
        }
        return i;
    }

    /**
     * 团队报名
     * @param
     * @return int
     * @author 夏添
     * @date 2020/7/23 9:25
     */
    public int twoPerson(String name1, String sex1, int age1, String idcard1, String name2,String sex2,int age2,String idcard2, String name3,String sex3,int age3,String idcard3, String phone){
        int i =0;
        try{
            i += personDao.CreatPerson(name1,sex1,age1,"家庭组",phone,idcard1,"",1);
            i += personDao.CreatPerson(name2,sex2,age2,"家庭组",phone,idcard2,"",1);
            i += personDao.CreatPerson(name3,sex3,age3,"家庭组",phone,idcard3,"",1);
        }catch (Exception e){
            e.printStackTrace();
        }
        return i;
    }

    /**
     * 统计个人男子组报名数
     * @param
     * @return int
     * @author 夏添
     * @date 2020/7/23 9:25
     */
    public int countOneman(){
        int count = 0;
        try {
            count = personDao.countEvent("个人男子组");
        }catch (Exception e){
            e.printStackTrace();
        }
        return count;
    }

    /**
     * 统计个人女子组报名数
     * @param
     * @return int
     * @author 夏添
     * @date 2020/7/23 9:25
     */
    public int countOnewoman(){
        int count = 0;
        try {
            count = personDao.countEvent("个人女子组");
        }catch (Exception e){
            e.printStackTrace();
        }
        return count;
    }

    /**
     * 统计个家庭组报名数
     * @param
     * @return int
     * @author 夏添
     * @date 2020/7/23 9:25
     */
    public int countTwo(){
        int count = 0;
        try {
            count = personDao.countEvent("家庭组");
        }catch (Exception e){
            e.printStackTrace();
        }
        return count;
    }

    /**
     * 统计个白衣天使组报名数
     * @param
     * @return int
     * @author 夏添
     * @date 2020/7/23 9:25
     */
    public int countThree(){
        int count = 0;
        try {
            count = personDao.countEvent("白衣天使组");
        }catch (Exception e){
            e.printStackTrace();
        }
        return count;
    }

    /**
     * 获取明细列表
     * @param pro
     * @return List<User>
     * @author 夏添
     * @date 2020/9/23 16:03
     */
    public List<Person> getPersonList(String pro){
        List<Person> list = new ArrayList<>();
        try {
            list = personDao.getPersonList(pro);
        }catch (Exception e){
            e.printStackTrace();
        }
        return list;
    }
}
